home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
IWF12.ZIP
/
IWF.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-20
|
29KB
|
891 lines
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IWF.C (Image WorkFrame)
AUTHOR: Craig Muller P. Eng. 1991,1992,1993
cmuller@ccu.umanitoba.ca
Computer Vision Laboratory
Mech. Engn.,Univ. of Manitoba
Winnipeg, Manitoba. R3T 2N2
DESCRIPTION:
This is the main program file for the Image WorkFrame
System or IWF for short. The purpose of this software is to provide a
general purpose program interface for image processing and image manipulation
in a windows environment. The code can be cut an pasted to produce other
programs of used as is. The program also allows the user to control the
MVP-AT image capture board to perform capture and store of images.
All the code is designed in a modular fashion so that projects in image
processing or conputer vision do not need to re-write all the basic code
for image manipulation. Each additional software project is designed as an
addition to the and has its own header file which is included here.
Programmers should limit their code modifications to the program module
which contains their project.
Coding conventions:
~~~ boxing for module title and description.
--- boxing for procedures which can be called by the user.
=== boxing for exports which cannot be called by the user.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <windows.h>
#pragma hdrstop
#include <stdio.h>
#include <string.h>
#include <io.h>
#include <math.h>
#include "iwf.h"
#include "module.h"
#define PGMNAME "IWF"
#define MODULE "IWF"
#define VGA 640 // VGA resolution width
#define SVGA 800 // Super VGA resolution width
#define XGA 1024 // XGA resolution width
#define CAD 1280 // CAD/CAM resolution width
//========================================
// Exported procedure prototypes.
//========================================
long far PASCAL _export WP_Main (HWND hWnd,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_About(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_Info(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_Scale(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_Transform(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_Frame(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
BOOL FAR PASCAL _export DP_UserFile(HWND hDlg,WORD wMsg,WORD wParam,LONG lParam);
//---------------------------------------
// Private procedures.
//---------------------------------------
static void Load_Settings(void);
int UserDlgMessage(MSG *msg);
int ToolDlgMessage(MSG *msg);
void Labeller(void);
void FillColors(void);
void iwf_FrameOp(int action);
int Load_Item(FILE *fp,char *keyword,int *buf,int cItems);
IMAGE *MedianImage(IMAGE *image);
IMAGE *SobelImage(IMAGE *image,WORD Threshold,BOOL Overlay);
//---------------------------------------
// Public variables.
//---------------------------------------
HANDLE hInst; /* current instance handle */
HWND _hWndImage [MAXIMAGES]; // Window handles for images.
HWND _hWndModule[MAXMODULES]; // Window handles for modules
HWND _hWndTool [MAXTOOLS]; // Window handles for buttons
HWND hWndMod=NULL; // Window handle for module.
HWND hWndSrc=NULL; // Window handle for source image.
HWND hWndDst=NULL; // Window handle for destination image.
char _name[8][20]; // Button names
char _cwdImage[80]; // Image working directory
IMAGE *_undo=NULL; // Undo image buffer pointer.
PALETTEENTRY peGray [64]; // Gray scale palette for gray images
PALETTEENTRY pePseudo[64]; // Pseudo color palette for alternate
PALETTEENTRY peUser [128]; // User programmable section
PALETTEENTRY peMain [256]; // Primary system palette
HPALETTE hPalMain; // Handle to the current palette.
extern WORD hist[256];
// Default user file profile
char _ext[5] = ".usr";
int _hsize = 0;
int _psize = 8;
int _pshift = 8;
int _width = 512;
int _height = 480;
//---------------------------------------
// Module prototypes.
//---------------------------------------
#if defined(MODULE0)
int MODULE0(HWND hWnd);
#endif
#if defined(MODULE1)
int MODULE1(HWND hWnd);
#endif
#if defined(MODULE2)
int MODULE2(HWND hWnd);
#endif
#if defined(MODULE3)
int MODULE3(HWND hWnd);
#endif
#if defined(MODULE4)
int MODULE4(HWND hWnd);
#endif
#if defined(MODULE5)
int MODULE5(HWND hWnd);
#endif
#if defined(MODULE6)
int MODULE6(HWND hWnd);
#endif
#if defined(MODULE7)
int MODULE7(HWND hWnd);
#endif
//--------------------------------------
// External dialog windows.
//--------------------------------------
#if defined (DIALOG0)
extern HWND DIALOG0;
#endif
#if defined (DIALOG1)
extern HWND DIALOG1;
#endif
#if defined (DIALOG2)
extern HWND DIALOG2;
#endif
#if defined (DIALOG3)
extern HWND DIALOG3;
#endif
#if defined (DIALOG4)
extern HWND DIALOG4;
#endif
#if defined (DIALOG5)
extern HWND DIALOG5;
#endif
#if defined (DIALOG6)
extern HWND DIALOG6;
#endif
#if defined (DIALOG7)
extern HWND DIALOG7;
#endif
/*
==========================================================================
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow)
Description:
WINDOWS ENTRY POINT CODE.
Windows initial entry point for the program. This is the startup code for
the program. It initializes the top level window, sets up code sharing
(if another instance of the program is running), and begins a message loop.
This code should not be modified by module programmers.
If this function must abort before entering the msg loop, it returns the
conventional value NULL.
==========================================================================
*/
int PASCAL WinMain(HANDLE hInstance, /* current instance */
HANDLE hPrevInstance, /* previous instance */
LPSTR lpCmdLine, /* cmd line */
int nCmdShow) /* show type (open/icon) */
{
int x0,y0,w,h,cx,cy;
MSG msg;
HWND hWnd;
WNDCLASS wc;
hInst = hInstance; // Save the instance handle.
if (!hPrevInstance) // Other instances running?
{
wc.lpszClassName = MODULE"Main"; // Name for CreateWindow.
wc.style = CS_DBLCLKS; // Qualifying double clicks
wc.lpfnWndProc = (WNDPROC)WP_Main; // Func to get msgs
wc.cbClsExtra = 0; // No per-class extra data.
wc.cbWndExtra = 0; // No per-window extra data
wc.hInstance = hInstance; // App that owns the class
wc.hIcon = LoadIcon(hInst,MODULE); // Loads icon
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = COLOR_APPWORKSPACE+1;
wc.lpszMenuName = MODULE; // Name of menu resource
if (!RegisterClass(&wc)) // Initialize new window class.
{
char sz[80];
sprintf("Unable to register <%s> class",(char *)wc.lpszClassName);
MessageBeep(MB_ICONEXCLAMATION);
MessageBox(NULL,sz,"Error",MB_OK | MB_ICONEXCLAMATION);
return (FALSE); // Exits if unable.
}
}
/*
Perform initializations that apply to a specific instance, those that
cannot be shared by multiple instances. Save the instance handle in
static variable, which will be used in many subsequence calls from
this application to Windows.
WRIPS is currently compatible with 3 display resolutions:
1. 640x480 VGA